import React ,{useEffect}from 'react'
import axios from 'axios'
import '../../api/list'
import { ProductCard, Tag, Button } from 'react-vant';
import {useDispatch,useSelector} from 'react-redux'
import {set} from '../../type/store.d'
import {useNavigate} from 'react-router-dom'
export default function Index() {
  const Navigate=useNavigate()
    const Dispatch=useDispatch()
    const sj=useSelector<set, any>((state:set)=>{
        return state.list
    })
    console.log(sj);
    const dj=(a:any)=>{
console.log(a);
Navigate(`/xq/${a.id}`,{state:a})
    }
    useEffect(()=>{
        axios.get('/list', {
            params: {}
          }).then((ret) => {
            Dispatch({
                type:"get",
                payload:ret.data.list
            })
            console.log(ret.data.list)
          })
    },[])
  return (
    <div>Index
        {sj&&sj.map((a:any,b:any)=>{
            return  <ProductCard key={b} onClick={()=>dj(a)}
      num={a.sl}
      price={a.num}
      desc={a.title}
      title={a.title}
      thumb={a.img}
    />
        })}
         
    </div>
  )
}
